package com.qk.management.service.Impl;

import cn.hutool.core.bean.BeanUtil;
import com.qk.common.anno.Cachedable;
import com.qk.common.constant.CacheConstants;
import com.qk.domain.Business.BusinessPortalDO;
import com.qk.domain.clue.CluePortalDO;
import com.qk.management.mapper.BusinessMapper;
import com.qk.management.mapper.ClueMapper;
import com.qk.management.service.ReportService;
import com.qk.vo.portal.OverviewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Slf4j
@Service
@SuppressWarnings("all")
public class ReportServiceImpl implements ReportService {

    @Autowired
    private ClueMapper clueMapper;
    @Autowired
    private BusinessMapper businessMapper;

    @Cachedable(
            redispreKey = CacheConstants.REDIS_CACHE_PREFIX,
            expireTime = 10,
            expireTimeUnit = TimeUnit.MINUTES)
    @Override
    public OverviewVO getOverview() {
        CluePortalDO clueOverviewVO = clueMapper.getClueOverviewData();
        BusinessPortalDO businessOverviewVO = businessMapper.getBusinessOverviewData();
        OverviewVO overviewVO = BeanUtil.copyProperties(businessOverviewVO, OverviewVO.class);
        BeanUtil.copyProperties(clueOverviewVO, overviewVO);
        return overviewVO;
    }
}